Chapter 1: Navigating the Filesystem
Learn the basics of moving around and understanding your Linux environment.
Linux Terminal
user@linux:~$ Type 'pwd' to see current directory
pwd β Print Working Directory
Show the absolute path of the current directory.
pwd
# Output: /home/user
Displays the full path from the root to your current location.
π‘ Practice: What command would you use to display your current directory?
cd [directory] β Change Directory
cd /home/user/Documents
cd .. # Go up one level
cd ~ # Go to home directory
cd - # Go to previous directory
Use
cd .. to go up one level, cd ~ for home directory.ls β List Directory Contents
ls
ls -la # Long format with hidden files
ls -lh # Human readable file sizes
ls -t # Sort by modification time
Which ls option shows hidden files?
Chapter 2: File Operations
Learn how to create, copy, move, and delete files and directories.
mkdir [directory] β Create Directory
mkdir new_folder
mkdir -p parent/child/grandchild # Create nested directories
mkdir dir1 dir2 dir3 # Create multiple directories
rm [file] β Remove Files/Directories
rm file.txt
rm -r directory/ # Remove directory recursively
rm -f file.txt # Force remove without confirmation
rm -i file.txt # Interactive mode (ask before removing)
β οΈ Be careful with rm -rf! It can delete your entire system if used incorrectly.
cp [src] [dest] β Copy Files
cp file.txt backup/
cp -r source/ destination/ # Copy directories recursively
cp -i file.txt backup/ # Interactive (ask before overwrite)
cp -v file.txt backup/ # Verbose (show what's being copied)
Challenge Create a backup of a directory with all its contents
Chapter 3: Text Processing
Powerful commands for working with text files.
cat [file] β Concatenate and Display
cat file.txt
cat file1.txt file2.txt > combined.txt # Combine files
cat > newfile.txt # Create new file (Ctrl+D to save)
grep [pattern] [file] β Search Text
grep "error" logfile.txt
grep -r "TODO" ./src/ # Recursive search
grep -i "warning" log.txt # Case-insensitive
grep -v "success" log.txt # Invert match (show non-matching lines)
Search Practice
user@linux:~$ Let's search for errors in a log file
Chapter 4: Permissions and Ownership
Understand Linux file permissions and security.
Permission
Description
r (4)
Read permission
w (2)
Write permission
x (1)
Execute permission
chmod [permissions] [file] β Change Permissions
chmod 755 script.sh
chmod u+x file.txt # Add execute for user
chmod go-w file.txt # Remove write for group and others
chmod -R 644 dir/ # Recursive change
chown [user]:[group] [file] β Change Ownership
chown user:group file.txt
chown user file.txt # Change user only
chown :group file.txt # Change group only
chown -R user:group dir/ # Recursive change
Chapter 5: Process Management
Control and monitor running processes.
ps β Process Status
ps aux # Show all processes
ps -ef # Full format listing
ps aux | grep nginx # Find specific process
kill [signal] [pid] β Terminate Processes
kill 1234 # Send TERM signal (default)
kill -9 1234 # Force kill (SIGKILL)
killall nginx # Kill all processes named nginx
β οΈ SIGKILL (-9) cannot be caught or ignored by the process. Use as last resort.
Comprehensive Quiz
Test your knowledge of Linux commands with this interactive quiz.
1. Which command would you use to find files modified in the last 24 hours?
2. How would you make a script executable for all users?